﻿using Map.GaoDe.Web.Domain;
using System;

namespace Map.GaoDe.Web
{
    public class SDK
    {
        /// <summary>
        /// 通过地址转坐标
        /// </summary>
        /// <param name="city"></param>
        /// <param name="address"></param>
        /// <returns></returns>
        public static GeoCode GetLocation(string city, string address)
        {
            var url = string.Format("http://restapi.amap.com/v3/geocode/geo?parameters&key={0}&address={1}&city={2}&output=json", Config.Key, address, city);
            var model = HttpHelper.Get<GeoModel>(url);
            if (model != null && model.geocodes != null && model.geocodes.Count > 0)
            {
                return model.geocodes[0];
            }
            else
            {
                return null;
            }
        }
    }
}
